home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************************/
- /* HelpWindowProc */
- /* */
- /* this procedure contains 16 toolbox calls which may move or purge memory */
- /* */
- /************************************************************************************/
-
- #include "HelpWindowProc.h"
- #ifndef __C14__
- #include "C14 Calculator.h"
- #endif
- #include "TE32K.h"
- #include "Globals.h"
- #include "HelpGetProc.h"
- #include "myActionProc.h"
- #include "HelpCloseProc.h"
- #include "helpCount.h"
-
- void HelpWindowSeg() {}
-
- short HelpWindowProc()
- {
- short HelpWindRetCode = 0;
- short isDebug = 0;
- short workPart;
- short h,v;
- short j,k;
- Rect sizeRect;
- ControlHandle workControlHandle;
- ControlActionUPP myControlProc;
-
- myControlProc = NewControlActionProc((ProcPtr) -1);
- SetPort (windTbl[1].windPtr); /* set as the grafPort */
-
- workPoint = gTheEvent.where;
- GlobalToLocal(&workPoint);
-
- switch (gTheEvent.what) /* how did I get here? */
- {
- case (mouseDown): /* MouseDown? */
- /*DebugStr("\pJust inside HelpWindowProc()! and case(mousedown)");*/
- isDebug = 1;
- switch (myMouseWhere) /* What part of window? */
- {
- case (inContent): /* content region: */
- workRect = (**helpList).rView; /* view area of list */
- workRect.right += 16; /* plus scroll bar */
- if (PtInRect(workPoint, &workRect)) /* if in the list area */
- {
- workBoolean = LClick (workPoint, gTheEvent.modifiers, helpList);
-
- for (j=0; j<helpCount; j++) /* find which cell is on */
- {
- helpCell.h = 0;
- helpCell.v = j;
- if (LGetSelect(FALSE, &helpCell, helpList))
- break;
- }
-
- if ((helpCell.v != helpPrev)
- && (j < helpCount))
- {
- helpPrev = helpCell.v;
- helpHandle = GetResource('TEXT', 1000 + helpCell.v);
- /************* GetResource(); may move memory */
- HLock (helpHandle);
- helpLong = SizeResource(helpHandle);
- EraseRect (&(**windTbl[1].windTEH[0]).viewRect);
- /************* EraseRect(); may move memory */
- TESetText (*helpHandle+32, helpLong-32,
- windTbl[1].windTEH[0]);
- /************* TESetText(); may move memory */
- HUnlock (helpHandle);
- ReleaseResource (helpHandle);
- /************* ReleaseResource(); may move memory */
- TECalText (windTbl[1].windTEH[0]);
- /************* TECalText(); may move memory */
- if ((**windTbl[1].windCntlH[0]).contrlValue > 0)
- TEScroll (0, (**windTbl[1].windCntlH[0]).contrlValue,
- windTbl[1].windTEH[0]);
- /************* TEScroll(); may move memory */
- myActionProc (windTbl[1].windCntlH[0], 0);
- InvalRect (&(**windTbl[1].windTEH[0]).viewRect);
- /************* InvalRect(); may move memory */
- }
- }
- else
- {
- /*DebugStr("\pRight before FindControl()!");*/
- workPart = FindControl (workPoint, /* check for control*/
- windTbl[1].windPtr,
- &workControlHandle);
- /************* FindControl(); may move memory */
- if (workPart) /* if so, track it */
- {
- if (workPart != inThumb) /* if not in thumb: my proc */
- { /* to scroll and reset thumb */
- /* on the basis of the scroll */
- /*DebugStr("\pRight before first TrackControl()!");*/
- #ifdef powerc
- TrackControl (workControlHandle, workPoint,
- (ControlActionUPP) -1);
- #else
- TrackControl (workControlHandle, workPoint, NIL);
- #endif
- /************* TrackControl(); may move memory */
- }
- else /* in thumb: use native routine */
- { /* then invoke my proc to */
- /* scroll on the basis of thumb */
- kkk = GetCtlValue (workControlHandle);
- /*DebugStr("\pRight before second TrackControl()!");*/
- TrackControl (workControlHandle, workPoint, NIL);
- /************* TrackControl(); may move memory */
- kkk -= GetCtlValue (workControlHandle);
- myActionProc(workControlHandle, (short) workPart);
- }
- }
- }
- break;
-
- case (inDrag): /* drag region: */
- DragWindow (windTbl[1].windPtr,
- gTheEvent.where, &gDragRect);
- /************* DragWindow(); may move memory */
- break;
-
- case (inGoAway): /* goaway region: */
- if (TrackGoAway (windTbl[1].windPtr, gTheEvent.where))
- WorkRetCode = HelpCloseProc();
- /************* TrackGoAway(); may move memory */
- break;
- }
-
- break;
-
- case (activateEvt):
- j = (int) BitAnd(gTheEvent.modifiers, activeFlag);
-
- if (j) /* if activate... */
- {
- /*WorkRetCode = MenuUpdate(ProcHelp);*/ /* set menus */
- ShowControl (windTbl[1].windCntlH[0]);
- /************* ShowControl(); may move memory */
- HiliteControl (windTbl[1].windCntlH[0], 0);
- /************* HiliteControl(); may move memory */
- LActivate (TRUE, helpList);
- }
- else /* if deactivate... */
- {
- HiliteControl (windTbl[1].windCntlH[0], 255); /* unhilite */
- /************* HiliteControl(); may move memory */
- HideControl (windTbl[1].windCntlH[0]); /* hide (to match L/M) */
- /************* HideControl(); may move memory */
- LActivate (FALSE, helpList);
- }
- break;
- }
- if(isDebug) /*DebugStr("\pRight before return!");*/
- if(WorkRetCode == 99) HelpWindRetCode = WorkRetCode;
- return HelpWindRetCode;
- }
-